<script language="javascript">
	function hoanthanh()
	{
		opener.document.getElementById('dskh').innerHTML=document.getElementById('themdskh').innerHTML;
		close();
	}
</script>
</head>

<body>
<?php
	$ht=$_POST['hoten'];
	$cmnd=$_POST['cmnd'];
	$diachi=$_POST['diachi'];
	$dienthoai=$_POST['dienthoai'];
	$mail=$_POST['mail'];
	$tendn=$_POST['tendn'];
	$quyen=$_POST['quyen'];
	//echo $ht."<br>".$cmnd."<br>".$diachi."<br>".$dienthoai."<br>".$mail."<br>".$tendn."<br>".$quyen;
	//$an=$_POST['an'];
	$k=$knoi->queryCsdl('select max(makh) as max_makh from khachhang');
	$l=mysql_fetch_array($k);
	$max_makh=$l['max_makh'];
	if($max_makh=='')
		$makh='0000001';
	else
	{
		$makh=1 + $max_makh;
		$sl= 7 - count($makh);
		//echo $sl."<br>";
		for($i=0;$i<$sl;$i++)
		{
			$makh='0'.$makh;
		}
	}
	//echo "<br>".$makh;
	if($kq=$knoi->queryCsdl("insert into khachhang values('$makh','$ht','$cmnd','$diachi','$dienthoai','$mail')"))
		$ketqua=1;
	else
		$ketqua=0;
	if($knoi->queryCsdl("insert into taikhoan values('$tendn',md5('$tendn'),'$quyen','$makh')"))
		$kq=1;
	else
		$kq=0;
	if($ketqua==1 && $kq==1)
	{
	?>
		<script language="javascript">alert("Đã thêm người dùng thành công!");</script>
	<?php
		echo "<meta http-equiv='refresh' content='0;url=home_admin.php?module=danhsachnguoidung&object=nguoidung' />";
	}
	else
	{
	?>
		<script language="javascript">alert("Có lỗi xãy ra. Xin vui lòng kiểm tra lại!");</script>
	<?php
		echo "<meta http-equiv='refresh' content='0;url=home_admin.php?module=themnguoidung' />";
	}
?>